package com.LeeCode;

/**
 * 构成整天的下标对数目 II
 */

public class Code3185 {
    public static void main(String[] args) {
        int[] hours = {72, 48, 24, 3};
        System.out.println(new Code3185().countCompleteDayPairs(hours));
    }

    public long countCompleteDayPairs(int[] hours) {
        long ans = 0;
        int[] cnt = new int[24];
        for (int hour : hours) {
            int index = hour % 24;
            if (index == 0) ans += cnt[index];
            else ans += cnt[24 - index];
            cnt[index]++;
        }
        return ans;
    }
}
